package com.polaris.live.common

import assertk.Assert
import assertk.assertThat
import assertk.assertions.isNotNull
import java.util.Optional

/**
 * AssertExtension
 *
 * @author Created by lucas on 2023/10/19 11:51
 */

/**
 * 转换为assert
 */
fun <T> T.toAssertThat(name: String? = null): Assert<T> =
    assertThat(this, name)

/**
 * 转换为assert
 */
fun <T> Optional<T>.toAssertThat(name: String? = null): Assert<T> {
    return orElse(null).toAssertThat(name)
        .isNotNull()
}